package models

//入口滞港花费清单

type Spend1 struct {
	Inno1   string `gorm:"column:inno1"`
	Spend1  string `gorm:"column:spend1"`
	Object1 string `gorm:"column:object1"`
}

func GetAllSpend1(Spend1Param map[string]interface{}) (error, []Spend1, int64) {
	var spend1Data []Spend1
	page := Spend1Param["page"].(int)
	pageSize := Spend1Param["limit"].(int)
	searchText := Spend1Param["searchText"].(string)
	var total int64
	err := db.Table("spend1").Where("inno1 like ?", "%"+searchText+"%").Order("inno1 ASC").Count(&total).Find(&spend1Data).Offset((page - 1) * pageSize).Limit(pageSize).Error
	return err, spend1Data, total
}
func AddSpend1(spend1data Spend1) (error, Spend1) {
	err := db.Table("spend1").Select("inno1", "spedn1", "object1").Create(&spend1data).Error
	return err, spend1data
}

func UpdateSpend1(inno1 string, spend1data Spend1) (error, Spend1) {
	err := db.Table("spend1").Where("inno1 = ?", spend1data.Inno1).Updates(&spend1data).Error
	return err, spend1data
}

func DeleteSpend1(inno1 string) (error, Spend1) {
	var spend1data Spend1
	spend1data.Inno1 = inno1
	err := db.Table("spend1").Where("inno1 = ?", inno1).Find(&spend1data).Delete(Spend1{}).Error
	return err, spend1data
}
